import streamlit as st
import pandas as pd

# 生成数据
data = pd.DataFrame(
    {
        "name": ["张三", "李四", "王五", "赵六", "孙七"],
        "age": [18, 19, 20, 21, 22],
        "sex": ["男", "女", "男", "女", "男"],
        "city": ["北京", "上海", "广州", "深圳", "杭州"],
    }
)

# 显示交互式表格
st.dataframe(data)
st.dataframe(data.style.highlight_max(axis=0, color='yellow', subset=['age']))

# 显示静态表格（适合打印）
st.table(data)

# 读取数据
df = pd.read_csv('dataset.csv')
df = df.head()
st.dataframe(df)

# 展示代码
code_str = '''
print("hello world!")

def main():
    print("it is a teat!")
'''

st.code(code_str, language='python', line_numbers=True)  # line_numbers 显示行号
